<!DOCTYPE html><html><head><title>README</title><link href="http://www.jboss.org/jdf/stylesheets/documentation.css" rel="stylesheet"></link><link href="http://www.jboss.org/jdf/stylesheets/pygments.css" rel="stylesheet"></link></head><body>
<h1><a id="wicketear-wicket-framework-used-in-a-war-inside-an-ear" class="anchor" href="#wicketear-wicket-framework-used-in-a-war-inside-an-ear"><span class="anchor-icon"></span></a>wicket-ear: Wicket Framework used in a WAR inside an EAR.</h1>

<p>Author: Ondrej Zizka <a href="mailto:ozizka@redhat.com">ozizka@redhat.com</a><br/>
Level: Intermediate<br/>
Technologies: Apache Wicket, JPA<br/>
Summary: Demonstrates how to use the Wicket Framework 1.5 with the JBoss server using the Wicket-Stuff Java EE integration, packaged as an EAR<br/>
Target Product: EAP<br/>
Product Versions: EAP 6.1, EAP 6.2<br/>
Source: <a href="https://github.com/jboss-developer/jboss-eap-quickstarts/">https://github.com/jboss-developer/jboss-eap-quickstarts/</a>  </p>

<h2><a id="what-is-it" class="anchor" href="#what-is-it"><span class="anchor-icon"></span></a>What is it?</h2>

<p>This is an example of how to use Wicket Framework 1.5 with JBoss AS, leveraging features of Java EE 6, using the Wicket-Stuff Java EE integration.</p>

<p>Features used:</p>

<ul>
<li>Injection of <code>@PersistenceContext</code></li>
<li>Injection of a value from <code>web.xml</code> using <code>@Resource</code></li>
<li>Injection of a stateless session bean using <code>@EJB</code></li>
</ul>

<p>This is an EAR version, with the following structure:</p>
<div class="highlight"><pre>    <span class="o">-</span><span class="err">`</span><span class="n">wicket</span><span class="o">-</span><span class="n">ear</span><span class="err">`</span> <span class="o">-</span> <span class="n">parent</span> <span class="n">module</span>
        <span class="o">-</span> <span class="err">`</span><span class="n">ejb</span><span class="err">`</span><span class="o">:</span> <span class="n">Contains</span> <span class="n">EJB</span> <span class="n">beans</span> <span class="n">and</span> <span class="n">JPA</span> <span class="n">entities</span><span class="p">.</span> <span class="n">Creates</span> <span class="n">a</span> <span class="err">`</span><span class="p">.</span><span class="n">jar</span><span class="err">`</span> <span class="n">file</span>
        <span class="o">-</span> <span class="err">`</span><span class="n">war</span><span class="err">`</span><span class="o">:</span> <span class="n">Contains</span> <span class="n">the</span> <span class="n">Wicket</span> <span class="n">web</span> <span class="n">application</span><span class="p">,</span> <span class="n">which</span> <span class="n">uses</span> <span class="n">the</span> <span class="n">EJB</span> <span class="n">beans</span><span class="p">.</span> <span class="n">Creates</span> <span class="n">a</span> <span class="err">`</span><span class="p">.</span><span class="n">war</span><span class="err">`</span> <span class="n">file</span>
        <span class="o">-</span> <span class="err">`</span><span class="n">ear</span><span class="err">`</span><span class="o">:</span> <span class="n">Packages</span> <span class="n">the</span> <span class="n">EJB</span> <span class="n">JAR</span> <span class="n">and</span> <span class="n">WAR</span> <span class="n">into</span> <span class="n">an</span> <span class="n">EAR</span><span class="p">.</span> <span class="n">Creates</span> <span class="n">an</span> <span class="err">`</span><span class="p">.</span><span class="n">ear</span><span class="err">`</span> <span class="n">file</span>
</pre></div>
<h2><a id="system-requirements" class="anchor" href="#system-requirements"><span class="anchor-icon"></span></a>System requirements</h2>

<p>The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 6.1 or later. </p>

<p>All you need to build this project is Java 6.0 (Java SDK 1.6) or later, Maven 3.0 or later.</p>

<h2><a id="configure-maven" class="anchor" href="#configure-maven"><span class="anchor-icon"></span></a>Configure Maven</h2>

<p>If you have not yet done so, you must <a href="../README.html#configure-maven">Configure Maven</a> before testing the quickstarts.</p>

<h2><a id="start-the-jboss-server" class="anchor" href="#start-the-jboss-server"><span class="anchor-icon"></span></a>Start the JBoss Server</h2>

<ol>
<li>Open a command line and navigate to the root of the JBoss server directory.</li>
<li><p>The following shows the command line to start the server:</p>
<div class="highlight"><pre><span class="n">For</span> <span class="n">Linux</span><span class="o">:</span>   <span class="n">JBOSS_HOME</span><span class="o">/</span><span class="n">bin</span><span class="o">/</span><span class="n">standalone</span><span class="p">.</span><span class="n">sh</span>
<span class="n">For</span> <span class="n">Windows</span><span class="o">:</span> <span class="n">JBOSS_HOME</span><span class="err">\</span><span class="n">bin</span><span class="err">\</span><span class="n">standalone</span><span class="p">.</span><span class="n">bat</span>
</pre></div></li>
</ol>

<h2><a id="build-and-deploy-the-quickstart" class="anchor" href="#build-and-deploy-the-quickstart"><span class="anchor-icon"></span></a>Build and Deploy the Quickstart</h2>

<p><em>NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line. See <a href="../README.html#build-and-deploy-the-quickstarts">Build and Deploy the Quickstarts</a> for complete instructions and additional options.</em></p>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>Type this command to build and deploy the archive:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">clean</span> <span class="n">install</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">deploy</span>
</pre></div></li>
<li><p>This will deploy <code>target/jboss-wicket-ear.ear</code> to the running instance of the server.</p></li>
</ol>

<h2><a id="access-the-application-" class="anchor" href="#access-the-application-"><span class="anchor-icon"></span></a>Access the application </h2>

<p>The application will be running at the following URL: <a href="http://localhost:8080/jboss-wicket-ear-war/">http://localhost:8080/jboss-wicket-ear-war/</a>.</p>

<ul>
<li>You will see a page with a table listing the existing Contact entities. Initially, this table is empty.</li>
<li>Click on the <em>Insert a new Constact</em> link to add a new contact.</li>
</ul>

<h2><a id="undeploy-the-archive" class="anchor" href="#undeploy-the-archive"><span class="anchor-icon"></span></a>Undeploy the Archive</h2>

<ol>
<li>Make sure you have started the JBoss Server as described above.</li>
<li>Open a command line and navigate to the root directory of this quickstart.</li>
<li><p>When you are finished testing, type this command to undeploy the archive:</p>
<div class="highlight"><pre><span class="n">mvn</span> <span class="n">jboss</span><span class="o">-</span><span class="n">as</span><span class="o">:</span><span class="n">undeploy</span>
</pre></div></li>
</ol>

<h2><a id="run-the-quickstart-in-jboss-developer-studio-or-eclipse" class="anchor" href="#run-the-quickstart-in-jboss-developer-studio-or-eclipse"><span class="anchor-icon"></span></a>Run the Quickstart in JBoss Developer Studio or Eclipse</h2>

<p>You can also start the server and deploy the quickstarts from Eclipse using JBoss tools. For more information, see <a href="../README.html#use-jboss-developer-studio-or-eclipse-to-run-the-quickstarts">Use JBoss Developer Studio or Eclipse to Run the Quickstarts</a> </p>

<h2><a id="debug-the-application" class="anchor" href="#debug-the-application"><span class="anchor-icon"></span></a>Debug the Application</h2>

<p>If you want to debug the source code or look at the Javadocs of any library in the project, run either of the following commands to pull them into your local repository. The IDE should then detect them.</p>
<div class="highlight"><pre>    <span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">sources</span>
    <span class="n">mvn</span> <span class="n">dependency</span><span class="o">:</span><span class="n">resolve</span> <span class="o">-</span><span class="n">Dclassifier</span><span class="o">=</span><span class="n">javadoc</span>
</pre></div></body></html>
